from rest_framework import serializers
from .models import Area

class AreadInfoSerializer(serializers.ModelSerializer):
    class Meta:
        model = Area
        fields = ("id", "name")  # 返回对应id

class AreaSubsInfoSerializer(serializers.ModelSerializer):
    subs = AreadInfoSerializer(read_only=True, many=True)

    class Meta:
        model = Area
        fields = ("id", "name", "subs")


